varying vec3 normal, lightVec, viewerVec;

void main()
{	
	vec4 I, Ia, Id, Is;
	vec3 n, lv, rv, vv;
	float NdotL, RdotV, power;

	n  = normalize( normal );
	lv = normalize( lightVec );
	vv = normalize( viewerVec );

	rv = normalize( 2.0 * dot( n, lv ) * n - lv );	

	NdotL = dot( n, lv );
	RdotV = dot( rv, vv );
	power = pow( RdotV, gl_FrontMaterial.shininess );

	Ia = gl_LightSource[0].ambient * gl_FrontMaterial.ambient;
	Id = gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse * max( NdotL, 0.0 ) ;
	Is = gl_LightSource[0].specular * gl_FrontMaterial.specular * power;

	I = Ia + Id + Is;

	gl_FragColor = I;
	//gl_FragColor = gl_Color;
} 
 